#include "ptmr_config.h"
#include "sdk_project_config.h"
#include "ptmr.h"
#include "ec20.h"
#include "bsp_timer.h"
#include "M10.h"
#include "gpio.h"
#include "mqtt_socket.h"

#define PTMR_INST (0)

uint32_t system_tick_ms = 1;

void pTMR0_Ch0_IRQHandler(void)
{
    pTMR_DRV_ClearInterruptFlagTimerChannels(PTMR_INST, pTMR0_CH0);
    /* Note: Debug output inserted into interrupt routine for demo clarity. Might introduce delay. */
    if(++system_tick_ms == 4294967000)
	{
		system_tick_ms = 0;
	}
	update_timestamp();
	status_led_ctl();
	mqtt_keep_alive_ctl();
	EC20_uart_rx_timer_isr();
	bynav_uart_rx_timer_isr();
}


void pTMR_init(void)
{
    pTMR_DRV_Init(PTMR_INST,&PTMR_Config);
    pTMR_DRV_InitChannel(PTMR_INST, pTMR0_CH0, &ptmr_channel_0);
    pTMR_DRV_StartTimerChannels(PTMR_INST, pTMR0_CH0);
}





